<?php
/**
 * @version $Id: oonfig.xposters.php 001 2007-09-09 18:34:23Z userxp $
 * @package  XPosters
 *
 * XPosterS Primary Class File
 * @copyright Copyright (C) 2005-2007 JoomlaTune Projects. All rights reserved.
 * @license http://creativecommons.org/ Creative Common License
 * @developed by Alexey Brin aka UserXP
 * 
 * web: http://joomlatune.ru
 * email: userxp@joomlaportal.ru
 *
 **/

defined('_VALID_MOS') or defined('_JEXEC') or die('Direct Access to this location is not allowed.');

/*$jxlib = & JXLibrary::getInstance();
$lib = $jxlib->base.DS.'html'.DS.'element.php';

if( file_exists( $lib )) {
	include_once( $lib );
}*/

class JXHtmlLabel extends JXHtmlElement
{
	var $start_tag	= 'label';
	var $finish_tag	= 'label';
	
	function JXHtmlLabel( $for, $text )
	{
		$this->__construct( $for, $text );
	} //JXHtmlLabel
	
	function __construct( $for, $text )
	{
		$this->setParameter( 'for', $for );
		$this->inner_text = strval( $text );
	} //__construct
	
	function create( $for, $text )
	{
		$this->setParameter( 'for', $for );
		$this->inner_text = strval( $text );
		
		return $this->build( false );
	}
	
} //JXHtmlLabel

class JXHtmlInput extends JXHtmlElement
{
	var $start_tag	= 'input';
	var $finish_tag	= '';
	var $label		= '';
	
	function JXHtmlInput( $id='', $name='', $value='', $options=null )
	{
		$this->__construct( $id, $name, $value, $options );
	}
	
	function __construct( $id='', $name='', $value='', $options=null )
	{
		$this->setOptions( $options );
		if( $id )	$this->setParameter( 'id', $id );
		if( $name )	$this->setParameter( 'name', $name );
		if( $value )	$this->setParameter( 'value', $value );
		
		$this->init();
	}
	
	function init()
	{
		$this->setParameter( 'type', 'text' );
		$this->setParameter( 'class', 'inputbox' );
	}
	
	function create( $id='', $name='', $value='', $class='', $options=null )
	{
		//$this->options = array();
		$this->init();
		
		$this->setOptions( $options );
		
		if( $id )	$this->setParameter( 'id', $id );
		if( $name )	$this->setParameter( 'name', $name );
		if( $value )	$this->setParameter( 'value', $value );
		if( $class )	$this->setParameter( 'class', $class ); // does this prevention necessary?
		
		return $this->build( false, false, false );
	}
}

class JXHtmlHidden extends JXHtmlInput
{
	var $indent		= "\n  ";
	
	function JXHtmlHidden( $name='', $value='' )
	{
		$this->__construct( $name, $value );
	}
	
	function __construct( $name='', $value='' )
	{
		parent::__construct( '', $name, $value );
		$this->setParameter( 'value', $value ); // EXCEPTION: allowing empty value be written
	}
	
	function init()
	{
		$this->setParameter( 'type', 'hidden' );
	}
}

class JXHtmlButton extends JXHtmlInput
{
	function init()
	{
		$this->setParameter( 'type', 'button' );
	}
}

class JXHtmlRadio extends JXHtmlInput
{
	function init()
	{
		$this->setParameter( 'type', 'radio' );
	}
}

class JXHtmlCheckBox extends JXHtmlInput
{
	function init()
	{
		$this->setParameter( 'type', 'checkbox' );
	}
	function & getInstance ()
	{
		static $instance;
		if( !isset( $instance ) )
		{
			$instance = new JXHtmlCheckBox();
		}
		return $instance;
	} //getInstance
	function get( $id='', $name='', $value='', $class='', $options=null )
	{
		$a = & JXHtmlCheckBox::getInstance();
		$a->options = array(); // clear ?
		$a->setOptions( $options );
		$a->init();
		
		if( $id )	$a->setParameter( 'id', $id );
		if( $name )	$a->setParameter( 'name', $name );
		if( $class )	$a->setParameter( 'class', $class );
		
		/** external text heandler for LABEL ???? **/
		if( $value ) {
			$a->setParameter( 'checked', 'checked' );
			$a->setParameter( 'value', '1' );
		}
		else {
			$a->unsetParameter( 'checked' );
			$a->setParameter( 'value', '1' );
		}
		
		return $a->build( false, true, true );
	} //get
}

class JXHtmlForm extends JXHtmlElement
{
	var $start_tag	= 'form';
	var $finish_tag	= 'form';
	var $indent		= "\n";
	
	function init()
	{
		$this->setParameter( 'method', 'POST' );
		$this->setParameter( 'action', 'index2.php' );
		$this->setParameter( 'name', 'adminForm' );
	}
	
	function create( $method='POST', $action='index2.php', $name='adminForm', $options=null )
	{
		
	}
}
?>